#pragma once

struct DisseminationField;
struct ReqUserLoginField;
struct RspUserLoginField;
struct UserLogoutField;
struct ForceUserLogoutField;
struct ReqAuthenticateField;
struct RspAuthenticateField;
struct AuthenticationInfoField;
struct RspUserLogin2Field;
struct TransferHeaderField;
struct TransferBankToFutureReqField;
struct TransferBankToFutureRspField;
struct TransferFutureToBankReqField;
struct TransferFutureToBankRspField;
struct TransferQryBankReqField;
struct TransferQryBankRspField;
struct TransferQryDetailReqField;
struct TransferQryDetailRspField;
struct RspInfoField;
struct ExchangeField;
struct ProductField;
struct InstrumentField;
struct BrokerField;
struct TraderField;
struct InvestorField;
struct TradingCodeField;
struct PartBrokerField;
struct SuperUserField;
struct SuperUserFunctionField;
struct InvestorGroupField;
struct TradingAccountField;
struct InvestorPositionField;
struct InstrumentMarginRateField;
struct InstrumentCommissionRateField;
struct DepthMarketDataField;
struct InstrumentTradingRightField;
struct BrokerUserField;
struct BrokerUserPasswordField;
struct BrokerUserFunctionField;
struct TraderOfferField;
struct SettlementInfoField;
struct InstrumentMarginRateAdjustField;
struct ExchangeMarginRateField;
struct ExchangeMarginRateAdjustField;
struct ExchangeRateField;
struct SettlementRefField;
struct CurrentTimeField;
struct CommPhaseField;
struct LoginInfoField;
struct LogoutAllField;
struct FrontStatusField;
struct UserPasswordUpdateField;
struct InputOrderField;
struct OrderField;
struct ExchangeOrderField;
struct ExchangeOrderInsertErrorField;
struct InputOrderActionField;
struct OrderActionField;
struct ExchangeOrderActionField;
struct ExchangeOrderActionErrorField;
struct ExchangeTradeField;
struct TradeField;
struct UserSessionField;
struct QryMaxOrderVolumeField;
struct SettlementInfoConfirmField;
struct SyncDepositField;
struct SyncFundMortgageField;
struct BrokerSyncField;
struct SyncingInvestorField;
struct SyncingTradingCodeField;
struct SyncingInvestorGroupField;
struct SyncingTradingAccountField;
struct SyncingInvestorPositionField;
struct SyncingInstrumentMarginRateField;
struct SyncingInstrumentCommissionRateField;
struct SyncingInstrumentTradingRightField;
struct QryOrderField;
struct QryTradeField;
struct QryInvestorPositionField;
struct QryTradingAccountField;
struct QryInvestorField;
struct QryTradingCodeField;
struct QryInvestorGroupField;
struct QryInstrumentMarginRateField;
struct QryInstrumentCommissionRateField;
struct QryInstrumentTradingRightField;
struct QryBrokerField;
struct QryTraderField;
struct QrySuperUserFunctionField;
struct QryUserSessionField;
struct QryPartBrokerField;
struct QryFrontStatusField;
struct QryExchangeOrderField;
struct QryOrderActionField;
struct QryExchangeOrderActionField;
struct QrySuperUserField;
struct QryExchangeField;
struct QryProductField;
struct QryInstrumentField;
struct QryDepthMarketDataField;
struct QryBrokerUserField;
struct QryBrokerUserFunctionField;
struct QryTraderOfferField;
struct QrySyncDepositField;
struct QrySettlementInfoField;
struct QryExchangeMarginRateField;
struct QryExchangeMarginRateAdjustField;
struct QryExchangeRateField;
struct QrySyncFundMortgageField;
struct QryHisOrderField;
struct OptionInstrMiniMarginField;
struct OptionInstrMarginAdjustField;
struct OptionInstrCommRateField;
struct OptionInstrTradeCostField;
struct QryOptionInstrTradeCostField;
struct QryOptionInstrCommRateField;
struct IndexPriceField;
struct InputExecOrderField;
struct InputExecOrderActionField;
struct ExecOrderField;
struct ExecOrderActionField;
struct QryExecOrderField;
struct ExchangeExecOrderField;
struct QryExchangeExecOrderField;
struct QryExecOrderActionField;
struct ExchangeExecOrderActionField;
struct QryExchangeExecOrderActionField;
struct ErrExecOrderField;
struct QryErrExecOrderField;
struct ErrExecOrderActionField;
struct QryErrExecOrderActionField;
struct OptionInstrTradingRightField;
struct QryOptionInstrTradingRightField;
struct InputForQuoteField;
struct ForQuoteField;
struct QryForQuoteField;
struct ExchangeForQuoteField;
struct QryExchangeForQuoteField;
struct InputQuoteField;
struct InputQuoteActionField;
struct QuoteField;
struct QuoteActionField;
struct QryQuoteField;
struct ExchangeQuoteField;
struct QryExchangeQuoteField;
struct QryQuoteActionField;
struct ExchangeQuoteActionField;
struct QryExchangeQuoteActionField;
struct OptionInstrDeltaField;
struct ForQuoteRspField;
struct StrikeOffsetField;
struct QryStrikeOffsetField;
struct InputBatchOrderActionField;
struct BatchOrderActionField;
struct ExchangeBatchOrderActionField;
struct QryBatchOrderActionField;
struct CombInstrumentGuardField;
struct QryCombInstrumentGuardField;
struct InputCombActionField;
struct CombActionField;
struct QryCombActionField;
struct ExchangeCombActionField;
struct QryExchangeCombActionField;
struct ProductExchRateField;
struct QryProductExchRateField;
struct QryForQuoteParamField;
struct ForQuoteParamField;
struct MMOptionInstrCommRateField;
struct QryMMOptionInstrCommRateField;
struct MMInstrumentCommissionRateField;
struct QryMMInstrumentCommissionRateField;
struct InstrumentOrderCommRateField;
struct QryInstrumentOrderCommRateField;
struct TradeParamField;
struct InstrumentMarginRateULField;
struct FutureLimitPosiParamField;
struct LoginForbiddenIPField;
struct IPListField;
struct InputOptionSelfCloseField;
struct InputOptionSelfCloseActionField;
struct OptionSelfCloseField;
struct OptionSelfCloseActionField;
struct QryOptionSelfCloseField;
struct ExchangeOptionSelfCloseField;
struct QryOptionSelfCloseActionField;
struct ExchangeOptionSelfCloseActionField;
struct SyncDelaySwapField;
struct QrySyncDelaySwapField;
struct InvestUnitField;
struct QryInvestUnitField;
struct SecAgentCheckModeField;
struct SecAgentTradeInfoField;
struct MarketDataField;
struct MarketDataBaseField;
struct MarketDataStaticField;
struct MarketDataLastMatchField;
struct MarketDataBestPriceField;
struct MarketDataBid23Field;
struct MarketDataAsk23Field;
struct MarketDataBid45Field;
struct MarketDataAsk45Field;
struct MarketDataUpdateTimeField;
struct MarketDataBandingPriceField;
struct MarketDataExchangeField;
struct SpecificInstrumentField;
struct InstrumentStatusField;
struct QryInstrumentStatusField;
struct InvestorAccountField;
struct PositionProfitAlgorithmField;
struct DiscountField;
struct QryTransferBankField;
struct TransferBankField;
struct QryInvestorPositionDetailField;
struct InvestorPositionDetailField;
struct TradingAccountPasswordField;
struct MDTraderOfferField;
struct QryMDTraderOfferField;
struct QryNoticeField;
struct NoticeField;
struct UserRightField;
struct QrySettlementInfoConfirmField;
struct LoadSettlementInfoField;
struct BrokerWithdrawAlgorithmField;
struct TradingAccountPasswordUpdateV1Field;
struct TradingAccountPasswordUpdateField;
struct QryCombinationLegField;
struct QrySyncStatusField;
struct CombinationLegField;
struct SyncStatusField;
struct QryLinkManField;
struct LinkManField;
struct QryBrokerUserEventField;
struct BrokerUserEventField;
struct QryContractBankField;
struct ContractBankField;
struct InvestorPositionCombineDetailField;
struct ParkedOrderField;
struct ParkedOrderActionField;
struct QryParkedOrderField;
struct QryParkedOrderActionField;
struct RemoveParkedOrderField;
struct RemoveParkedOrderActionField;
struct InvestorWithdrawAlgorithmField;
struct QryInvestorPositionCombineDetailField;
struct MarketDataAveragePriceField;
struct VerifyInvestorPasswordField;
struct UserIPField;
struct TradingNoticeInfoField;
struct TradingNoticeField;
struct QryTradingNoticeField;
struct QryErrOrderField;
struct ErrOrderField;
struct ErrorConditionalOrderField;
struct QryErrOrderActionField;
struct ErrOrderActionField;
struct QryExchangeSequenceField;
struct ExchangeSequenceField;
struct QryMaxOrderVolumeWithPriceField;
struct QryBrokerTradingParamsField;
struct BrokerTradingParamsField;
struct QryBrokerTradingAlgosField;
struct BrokerTradingAlgosField;
struct QueryBrokerDepositField;
struct BrokerDepositField;
struct QryCFMMCBrokerKeyField;
struct CFMMCBrokerKeyField;
struct CFMMCTradingAccountKeyField;
struct QryCFMMCTradingAccountKeyField;
struct BrokerUserOTPParamField;
struct ManualSyncBrokerUserOTPField;
struct CommRateModelField;
struct QryCommRateModelField;
struct MarginModelField;
struct QryMarginModelField;
struct EWarrantOffsetField;
struct QryEWarrantOffsetField;
struct QryInvestorProductGroupMarginField;
struct InvestorProductGroupMarginField;
struct QueryCFMMCTradingAccountTokenField;
struct CFMMCTradingAccountTokenField;
struct QryProductGroupField;
struct ProductGroupField;
struct BulletinField;
struct QryBulletinField;
struct MulticastInstrumentField;
struct QryMulticastInstrumentField;
struct AppIDAuthAssignField;
struct ReqOpenAccountField;
struct ReqCancelAccountField;
struct ReqChangeAccountField;
struct ReqTransferField;
struct RspTransferField;
struct ReqRepealField;
struct RspRepealField;
struct ReqQueryAccountField;
struct RspQueryAccountField;
struct FutureSignIOField;
struct RspFutureSignInField;
struct ReqFutureSignOutField;
struct RspFutureSignOutField;
struct ReqQueryTradeResultBySerialField;
struct RspQueryTradeResultBySerialField;
struct ReqDayEndFileReadyField;
struct ReturnResultField;
struct VerifyFuturePasswordField;
struct VerifyCustInfoField;
struct VerifyFuturePasswordAndCustInfoField;
struct DepositResultInformField;
struct ReqSyncKeyField;
struct RspSyncKeyField;
struct NotifyQueryAccountField;
struct TransferSerialField;
struct QryTransferSerialField;
struct NotifyFutureSignInField;
struct NotifyFutureSignOutField;
struct NotifySyncKeyField;
struct QryAccountregisterField;
struct AccountregisterField;
struct OpenAccountField;
struct CancelAccountField;
struct ChangeAccountField;
struct SecAgentACIDMapField;
struct QrySecAgentACIDMapField;
struct UserRightsAssignField;
struct BrokerUserRightAssignField;
struct DRTransferField;
struct FensUserInfoField;
struct CurrTransferIdentityField;
struct LoginForbiddenUserField;
struct QryLoginForbiddenUserField;
struct TradingAccountReserveField;
struct QryLoginForbiddenIPField;
struct QryIPListField;
struct QryUserRightsAssignField;
struct ReserveOpenAccountConfirmField;
struct ReserveOpenAccountField;
struct AccountPropertyField;
struct QryCurrDRIdentityField;
struct CurrDRIdentityField;
struct QrySecAgentCheckModeField;
struct QrySecAgentTradeInfoField;
struct ReqUserAuthMethodField;
struct RspUserAuthMethodField;
struct ReqGenUserCaptchaField;
struct RspGenUserCaptchaField;
struct ReqGenUserTextField;
struct RspGenUserTextField;
struct ReqUserLoginWithCaptchaField;
struct ReqUserLoginWithTextField;
struct ReqUserLoginWithOTPField;
struct ReqApiHandshakeField;
struct RspApiHandshakeField;
struct ReqVerifyApiKeyField;
struct DepartmentUserField;
struct QueryFreqField;
struct AuthForbiddenIPField;
struct QryAuthForbiddenIPField;
struct SyncDelaySwapFrozenField;
struct UserSystemInfoField;
struct AuthUserIDField;
struct AuthIPField;
struct QryClassifiedInstrumentField;
struct QryCombPromotionParamField;
struct CombPromotionParamField;
struct ReqUserLoginSMField;
struct QryRiskSettleInvstPositionField;
struct QryRiskSettleProductStatusField;
struct RiskSettleInvstPositionField;
struct RiskSettleProductStatusField;
struct SyncDeltaInfoField;
struct SyncDeltaProductStatusField;
struct SyncDeltaInvstPosDtlField;
struct SyncDeltaInvstPosCombDtlField;
struct SyncDeltaTradingAccountField;
struct SyncDeltaInitInvstMarginField;
struct SyncDeltaDceCombInstrumentField;
struct SyncDeltaInvstMarginRateField;
struct SyncDeltaExchMarginRateField;
struct SyncDeltaOptExchMarginField;
struct SyncDeltaOptInvstMarginField;
struct SyncDeltaInvstMarginRateULField;
struct SyncDeltaOptInvstCommRateField;
struct SyncDeltaInvstCommRateField;
struct SyncDeltaProductExchRateField;
struct SyncDeltaDepthMarketDataField;
struct SyncDeltaIndexPriceField;
struct SyncDeltaEWarrantOffsetField;
struct SPBMFutureParameterField;
struct SPBMOptionParameterField;
struct SPBMIntraParameterField;
struct SPBMInterParameterField;
struct SyncSPBMParameterEndField;
struct QrySPBMFutureParameterField;
struct QrySPBMOptionParameterField;
struct QrySPBMIntraParameterField;
struct QrySPBMInterParameterField;
struct SPBMPortfDefinitionField;
struct SPBMInvestorPortfDefField;
struct InvestorPortfMarginRatioField;
struct QrySPBMPortfDefinitionField;
struct QrySPBMInvestorPortfDefField;
struct QryInvestorPortfMarginRatioField;
struct InvestorProdSPBMDetailField;
struct QryInvestorProdSPBMDetailField;
struct PortfTradeParamSettingField;
struct InvestorTradingRightField;
struct MortgageParamField;
struct WithDrawParamField;
struct ThostUserFunctionField;
struct QryThostUserFunctionField;
struct SPBMAddOnInterParameterField;
struct QrySPBMAddOnInterParameterField;
struct QryInvestorCommoditySPMMMarginField;
struct QryInvestorCommodityGroupSPMMMarginField;
struct QrySPMMInstParamField;
struct QrySPMMProductParamField;
struct InvestorCommoditySPMMMarginField;
struct InvestorCommodityGroupSPMMMarginField;
struct SPMMInstParamField;
struct SPMMProductParamField;
struct QryTraderAssignField;
struct TraderAssignField;
struct InvestorInfoCntSettingField;
struct RCAMSCombProductInfoField;
struct RCAMSInstrParameterField;
struct RCAMSIntraParameterField;
struct RCAMSInterParameterField;
struct RCAMSShortOptAdjustParamField;
struct RCAMSInvestorCombPositionField;
struct InvestorProdRCAMSMarginField;
struct QryRCAMSCombProductInfoField;
struct QryRCAMSInstrParameterField;
struct QryRCAMSIntraParameterField;
struct QryRCAMSInterParameterField;
struct QryRCAMSShortOptAdjustParamField;
struct QryRCAMSInvestorCombPositionField;
struct QryInvestorProdRCAMSMarginField;
struct RULEInstrParameterField;
struct RULEIntraParameterField;
struct RULEInterParameterField;
struct QryRULEInstrParameterField;
struct QryRULEIntraParameterField;
struct QryRULEInterParameterField;
struct InvestorProdRULEMarginField;
struct QryInvestorProdRULEMarginField;
struct SyncDeltaSPBMPortfDefinitionField;
struct SyncDeltaSPBMInvstPortfDefField;
struct SyncDeltaSPBMFutureParameterField;
struct SyncDeltaSPBMOptionParameterField;
struct SyncDeltaSPBMIntraParameterField;
struct SyncDeltaSPBMInterParameterField;
struct SyncDeltaSPBMAddOnInterParamField;
struct SyncDeltaSPMMInstParamField;
struct SyncDeltaSPMMProductParamField;
struct SyncDeltaInvestorSPMMModelField;
struct SyncDeltaSPMMModelParamField;
struct SyncDeltaRCAMSCombProdInfoField;
struct SyncDeltaRCAMSInstrParameterField;
struct SyncDeltaRCAMSIntraParameterField;
struct SyncDeltaRCAMSInterParameterField;
struct SyncDeltaRCAMSSOptAdjParamField;
struct SyncDeltaRCAMSCombRuleDtlField;
struct SyncDeltaRCAMSInvstCombPosField;
struct SyncDeltaRULEInstrParameterField;
struct SyncDeltaRULEIntraParameterField;
struct SyncDeltaRULEInterParameterField;
struct IpAddrParamField;
struct QryIpAddrParamField;
struct TGIpAddrParamField;
struct QryTGIpAddrParamField;
struct TGSessionQryStatusField;
struct LocalAddrConfigField;
struct QryLocalAddrConfigField;
struct ReqQueryBankAccountBySecField;
struct RspQueryBankAccountBySecField;
struct ReqTransferBySecField;
struct RspTransferBySecField;
struct NotifyQueryFutureAccountBySecField;
struct ExitEmergencyField;
struct InvestorPortfMarginModelField;
struct InvestorPortfSettingField;
struct QryInvestorPortfSettingField;
struct UserPasswordUpdateFromSecField;
struct SettlementInfoConfirmFromSecField;
struct TradingAccountPasswordUpdateFromSecField;
struct RiskForbiddenRightField;
struct InvestorInfoCommRecField;
struct QryInvestorInfoCommRecField;
struct CombLegField;
struct QryCombLegField;
struct InputOffsetSettingField;
struct OffsetSettingField;
struct CancelOffsetSettingField;
struct QryOffsetSettingField;
struct AddrAppIDRelationField;
struct QryAddrAppIDRelationField;
struct WechatUserSystemInfoField;
struct InvestorReserveInfoField;
struct QryInvestorDepartmentFlatField;
struct InvestorDepartmentFlatField;
struct QryDepartmentUserField;
struct FrontInfoField;

struct MdApi;
struct MdSpi;

#include "ctp-rs/src/lib.rs.h"
#include "ctp-rs/wrapper/include/CMdSpi.h"
#include "ctp-rs/lib/ThostFtdcMdApi.h"
#include "ctp-rs/lib/ThostFtdcTraderApi.h"

#include "rust/cxx.h"
#include <memory>

struct MdApi {
    MdApi(const MdSpi &gateway, rust::String flow_path, bool is_using_udp, bool is_multicast, bool is_production_mode);

    rust::String GetApiVersion() const;
    void Release() const;
    void Init() const;
    int32_t Join() const;
    rust::String GetTradingDay() const;
    void RegisterFront(rust::String pszFrontAddress) const;
    void RegisterNameServer(rust::String pszNsAddress) const;
    void RegisterFensUserInfo(FensUserInfoField pFensUserInfo) const;
    int32_t SubscribeMarketData(rust::Vec<rust::String> ppInstrumentID, int32_t nCount) const;
    int32_t UnSubscribeMarketData(rust::Vec<rust::String> ppInstrumentID, int32_t nCount) const;
    int32_t SubscribeForQuoteRsp(rust::Vec<rust::String> ppInstrumentID, int32_t nCount) const;
    int32_t UnSubscribeForQuoteRsp(rust::Vec<rust::String> ppInstrumentID, int32_t nCount) const;
    int32_t ReqUserLogin(ReqUserLoginField pReqUserLoginField, int32_t nRequestID) const;
    int32_t ReqUserLogout(UserLogoutField pUserLogout, int32_t nRequestID) const;
    int32_t ReqQryMulticastInstrument(QryMulticastInstrumentField pQryMulticastInstrument, int32_t nRequestID) const;

    const MdSpi &gateway;
    CThostFtdcMdApi *api;
    CMdSpi *spi;
};

std::unique_ptr<MdApi> CreateMdApi(const MdSpi &gateway, rust::String flow_path, bool is_using_udp, bool is_multicast, bool is_production_mode);
